package com.csd.action.teacher;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.csd.helper.ActionResult;
import com.csd.helper.IConstant;
import com.csd.helper.SessionManager;
import com.csd.pojo.Student;
import com.csd.pojo.Team;
import com.csd.serviceImpl.StudentService;
import com.csd.serviceImpl.TeamService;
import com.csd.serviceImpl.ProjectService;
import com.csd.vo.UserVO;
/**
 * 
 * 获得团队信息Action类
 * @author 尹华彬
 * @version 1.0
 * 
 * <br> 修订时间：2009-12-17
 * <br> 修改原因：创建文件
 * <br> 修改人：尹华彬
 * 
 * <br> 
 * 
 */
public class TeamInfoAction {
	//项目ID
	private Integer projectID;
	//项目成员
	private List<Student>   members;
	//团队服务类
    private TeamService teamService;
    
    private StudentService studentService;
    private Team team;
    
	public Team getTeam() {
		return team;
	}

	public void setTeam(Team team) {
		this.team = team;
	}

	public TeamService getTeamService() {
		return teamService;
	}

	public void setTeamService(TeamService teamService) {
		this.teamService = teamService;
	}

	public Integer getProjectID() {
		return projectID;
	}

	public void setProjectID(Integer projectID) {
		this.projectID = projectID;
	}

	public List<Student> getMembers() {
		return members;
	}

	public void setMembers(List<Student> members) {
		this.members = members;
	}
	
	public String execute(){
		
		String result = ActionResult.fail;
		Integer teacherID = null;
		try {
			HttpSession httpSession = ServletActionContext.getRequest().getSession();
			UserVO value = (UserVO)httpSession.getAttribute(IConstant.userVO);
			if(value == null){
				throw  new Exception("用户未登录异常");
			}
			teacherID = value.getUserID();
		} catch (Exception e) {
			e.printStackTrace();
			return result;
		}
	    team = teamService.getTeamByProjectID(projectID);
	    members = studentService.listStudentByTeam(team);
	    result = ActionResult.success;
		return result;
	}

}
